package com.twopai.framelibrary.mvp;

import android.os.Bundle;
import android.util.Log;

import androidx.annotation.IdRes;
import androidx.annotation.Nullable;

import com.gyf.immersionbar.ImmersionBar;
import com.twopai.framelibrary.R;
import com.twopai.mvpbase.BasePresenter;

/**
 * Author:twopai
 * Description:
 */
public abstract class BaseStatusActivity<T extends BasePresenter> extends BaseMvpActivity {
    protected ImmersionBar mImmersionBar;
    @Override
    protected void onResume() {
        super.onResume();
        int toolBar = setToolBarId();
        if (toolBar == -1&&toolBar!=2131297114) {
            //设置共同沉浸式样式
            ImmersionBar.with(this).navigationBarColor(R.color.colorPrimary).init();
        }else {
            initSetImmersionBar(toolBar,true);
        }
    }

    protected abstract int setToolBarId();

    public void initSetImmersionBar(@IdRes int viewId, boolean isStatusBarDarkFont){
        //初始化沉浸式
        Log.e("initSetImmersionBar","viewId="+viewId);
        initImmersionBar(viewId,isStatusBarDarkFont);
    }
    public void initSetImmersionBar(@IdRes int viewId,boolean isStatusBarDarkFont,boolean keyboardEnable){
        //初始化沉浸式
        Log.e("initSetImmersionBar","viewId="+viewId);
        initImmersionBar(viewId,isStatusBarDarkFont,keyboardEnable);
    }

    protected void initImmersionBar(@IdRes int viewId,boolean isStatusBarDarkFont,boolean keyboardEnable) {
        //在BaseActivity里初始化
        mImmersionBar = ImmersionBar.with(this);
        if (viewId != -1&&viewId!=2131297114) {
            mImmersionBar
                    .keyboardEnable(keyboardEnable)  //解决软键盘与底部输入框冲突问题
                    .statusBarDarkFont(isStatusBarDarkFont)
                    .titleBar(viewId)
                    .init();
        }
    }
    protected void initImmersionBar(@IdRes int viewId, boolean isStatusBarDarkFont) {
        //在BaseActivity里初始化
        mImmersionBar = ImmersionBar.with(this);
        if (viewId != -1&&viewId!=2131297114) {
            Log.e("initImmersionBar","viewId="+viewId);
            mImmersionBar
                    .statusBarDarkFont(isStatusBarDarkFont)
                    .titleBar(viewId)
                    .init();
        }
    }
}
